package com.uw.scenic.constant;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 异常码枚举类
 */
@Getter
@AllArgsConstructor
public enum ExceptionCodeEnum {

    PARAM_CODE("统一参数验证异常码",-9);

    /**
     * 异常描述（分类）
     */
    private String description;


    /**
     * 异常编码
     */
    private Integer code;


    public static ExceptionCodeEnum of(int code){
        Objects.requireNonNull(code);
        return Stream.of(values()).filter(bean->bean.code.equals(code)).findAny().orElseThrow(()->new IllegalArgumentException(code+"not exists!"));
    }
}
